# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python-pyperscan
_pkgname=${pkgname#python-}
pkgver=v0.3.0.r151.g25c2f5b
pkgrel=1
pkgdesc='Python binding for Hyperscan.'
arch=('x86_64' 'aarch64')
url='https://github.com/vlaci/pyperscan'
license=('Apache-2.0' 'MIT')
depends=('python' 'hyperscan')
makedepends=('git' 'python-build' 'python-pip' 'rust' 'clang')
options=(!emptydirs)
source=("git+https://github.com/vlaci/$_pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

build() {
  cd $_pkgname

  python -m build --wheel --outdir="$startdir/dist"
}

package() {
  cd $_pkgname

  pip install \
    --verbose \
    --disable-pip-version-check \
    --no-warn-script-location \
    --ignore-installed \
    --no-compile \
    --no-deps \
    --root="$pkgdir" \
    --prefix=/usr \
    --no-index \
    --find-links="file://$startdir/dist" \
    $_pkgname
}

